package com.training.admin.entity.trainer;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.training.admin.entity.project.Project;
import com.training.admin.entity.trainee.IdmUser;
import com.training.admin.entity.trainee.Trainee;

/**
 * 培训讲师
 * @author Rockett
 *
 */
@Entity
@Table(name = "trainer")
public class Trainer {
    
	/**
	 * ID
	 */
    @Id
    @GeneratedValue
    private Long id;
    
    /**
     * 讲师姓名
     */
    private String name;
    /**
     * 讲师编号
     */
    private String code; 	
    /**
     * 讲师邮箱
     */
    private String email;
    /**
     * 是否认证
     */
    @Column(name = "is_certified")
    private boolean certified;
    /**
     * 讲师类型
     */
    private String trainerType;
	/**
	 * 讲师级别
	 */
    private String trainerLevel;
    
    private String trainerSupplier;
    
    private String trainerDescription;
    
    /** 认证日期 */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date certifiedDate;
    
    /** 授课时长 */
    private int trainingHour;
    /** 满意度 */
    private String satisfaction;

     


	/**
     * 是否可用
     */
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public Trainer() {
    	this.disabled=false;
    }
    
    /**
     * 
     * @param trainee
     * @param project
     */
    public Trainer(Trainee trainee, Project project) {
    	
    	this.name = trainee.getName();
    	this.code = trainee.getCode();
    	this.email = trainee.getEmail();
    	this.certifiedDate = new Date();
    	this.trainerType = project.getSecondCategory().getName()+"-" + project.getFirstCategory().getName();
   
    };
    
    /**
     * 
     * @param project
     * @return
     */
    public Trainer certified(Project project) {
		this.certified = true;
		this.certifiedDate = new Date();
		this.trainerType = project.getSecondCategory().getName()+"-"+project.getFirstCategory().getName();
		return this;
    }
    
    /**
     * 
     * @return
     */
    public Trainer create() {
    	
    	this.code = ""+ new Date().getTime();
    	return this;
    }
    
    
    /**
     * @param name
     */
    public Trainer(String name) {
        this.id = new Long(1);
        this.name = name;
        this.disabled = false;
    }
    
    /**
     * @param idmUser
     * @return
     */
    public Trainer(IdmUser idmUser) {
        this.name = idmUser.getUsercn();
        this.code = idmUser.getUsernumber();
        this.email = idmUser.getMail();
        this.disabled = false;
    }
    
    public Trainer(String traineeName, String supplier, String trainerdesc) {
        this.name = traineeName;
        this.trainerSupplier = supplier;
        this.trainerDescription = trainerdesc;
        this.disabled = false;
    }
    
    /**
     * @param idmUser
     * @return
     */
    public Trainer updateByIdmuser(IdmUser idmUser) {
        this.name = idmUser.getUsercn();
        this.code = idmUser.getUsernumber();
        this.email = idmUser.getMail();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @return the certified
     */
    public boolean isCertified() {
        return certified;
    }

    /**
     * @return the trainerType
     */
    public String getTrainerType() {
        return trainerType;
    }

    /**
     * @return the trainerLevel
     */
    public String getTrainerLevel() {
        return trainerLevel;
    }

    /**
     * @return the trainerSupplier
     */
    public String getTrainerSupplier() {
        return trainerSupplier;
    }

    /**
     * @return the trainerDescription
     */
    public String getTrainerDescription() {
        return trainerDescription;
    }

    /**
     * @return the certifiedDate
     */
    public Date getCertifiedDate() {
        return certifiedDate;
    }

    /**
     * @return the trainingHour
     */
    public int getTrainingHour() {
        return trainingHour;
    }

    /**
     * @return the satisfaction
     */
    public String getSatisfaction() {
        return satisfaction;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * @param certified the certified to set
     */
    public void setCertified(boolean certified) {
        this.certified = certified;
    }

    /**
     * @param trainerType the trainerType to set
     */
    public void setTrainerType(String trainerType) {
        this.trainerType = trainerType;
    }

    /**
     * @param trainerLevel the trainerLevel to set
     */
    public void setTrainerLevel(String trainerLevel) {
        this.trainerLevel = trainerLevel;
    }

    /**
     * @param trainerSupplier the trainerSupplier to set
     */
    public void setTrainerSupplier(String trainerSupplier) {
        this.trainerSupplier = trainerSupplier;
    }

    /**
     * @param trainerDescription the trainerDescription to set
     */
    public void setTrainerDescription(String trainerDescription) {
        this.trainerDescription = trainerDescription;
    }

    /**
     * @param certifiedDate the certifiedDate to set
     */
    public void setCertifiedDate(Date certifiedDate) {
        this.certifiedDate = certifiedDate;
    }

    /**
     * @param trainingHour the trainingHour to set
     */
    public void setTrainingHour(int trainingHour) {
        this.trainingHour = trainingHour;
    }

    /**
     * @param satisfaction the satisfaction to set
     */
    public void setSatisfaction(String satisfaction) {
        this.satisfaction = satisfaction;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}